#include <iostream>
#include <cstdio>
#include <map>
#include <unordered_map>

using namespace std;

int MAX_LEN = 101;

int read_n() {
    int n = 0;
    cin >> n;
    return n;
}


// 记录字符串中每个字符出现的次数
unordered_map<char, int> build_source_count(string source) {
    unordered_map<char, int> source_count;


    for (auto iter_c = source.begin(); iter_c != source.end(); ++iter_c)
    {
        /* cout << *iter_c; */
        auto c = *iter_c;
        auto iter_map = source_count.find(c);
        if (iter_map == source_count.end()) {
            source_count.insert(pair<char, int>(c, 1));
        } else {
            auto p = *iter_map;
            iter_map->second += 1;
        }
    }

    // 测试自己map用法是正确的
    return source_count;
}

bool check(string to, string target, string source) {
    if (to.length() + source.length() < target.length()) {
        return false;
    }

    // source中每个字符出现的次数
    // 这里使用unordered_map 比map效率要好很多.
    unordered_map<char, int> source_count = build_source_count(source);

    auto to_idx = 0;
    auto iter_c = target.begin();
    for (     ; iter_c != target.end(); ++iter_c)
    {
        /* cout << *iter_c; */
        auto c = *iter_c;

        // 优先从to中获取, 因为to更严格, 需要顺序匹配.(这种贪心策略应该可以的)
        // 如果to中没有, 从source任意获取(判断计数即可)
        if (to_idx < to.length() && c == to[to_idx]) {
            to_idx += 1;
            continue;
        }

        auto iter_map = source_count.find(c);

        if (iter_map == source_count.end()) {
            return false;
        }

        auto p = *iter_map;

        if (iter_map -> second == 0) {
            return false;
        }


        iter_map->second -= 1;
    }

    return iter_c == target.end();      // 处理完毕, 表示匹配

}

bool run_case() {
    int n = read_n();
    getchar();

    for (int i = 0; i < n; i++) {
        string to ;
        string target ;
        string source ;

        getline(cin, to);
        getline(cin, target);
        getline(cin, source);

        int ret = check(to, target, source);
        if (ret) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        /* cout << "to " << to << endl; */
        /* cout << "tar " << target << endl; */
        /* cout << "source " << source << endl; */
    }

}


int main(int argc, char **argv)
{
    int ret = run_case();
    return 0;
}


